﻿using AutoMapper;
using Domain.Flow;
using MediatR;
using U.B.ErrorCode;
using U.B.Repistory;
using U.B.WriteApi.Command.RabbitBWss;

namespace U.B.WriteApi.CommandHander.RabbitBWDD
{
    public class UpdateKillCommmandHander : IRequestHandler<UpdateKillCommmand, ApiResult<object>>
    {
        public readonly IRepistory<Kill> _killRepository;
        public readonly IMapper _mapper;

        public UpdateKillCommmandHander(IRepistory<Kill> killRepository)
        {
            _killRepository = killRepository;
        }
        public Task<ApiResult<object>> Handle(UpdateKillCommmand request, CancellationToken cancellationToken)
        {
            ApiResult<object> apiResult=new ApiResult<object>();
            var result=_mapper.Map<Kill>(request);
            _killRepository.Update(result);
            apiResult.Data = result;
            apiResult.code = Renum.修改成功;
            apiResult.Message = Renum.修改成功.ToString();
            return Task.FromResult(apiResult);
        }
    }
}
